package Servlet;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Logic.CurriculumLogic;
import Logic.OperateLogic;
import Logic.TeacherLogic;
import Model.CurriculumBean;
import Model.MemberBean;
import Model.OperateBean;
import Model.TeacherBean;

@SuppressWarnings("serial")
public class CurriculumServlet extends HttpServlet{
	@Override
	public void doGet(HttpServletRequest request, HttpServletResponse response)
				throws ServletException, IOException {
		
		 response.setCharacterEncoding("utf-8");
		 response.setContentType("text/html;charset=utf-8");
		 PrintWriter out = response.getWriter();
		 String opType = request.getParameter("opType"); 
	}
		 
	    // 接收客户端浏览器的POST请求，由Service方法跳转
	@Override
	public void doPost(HttpServletRequest request, HttpServletResponse response)
	    		throws ServletException, IOException {		
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		PrintWriter out = response.getWriter();
		String opType = request.getParameter("opType");
		
		if (opType.equals("addCurriculum")){        	        	
			 String CurriculumID = request.getParameter("CurriculumID");
			 String CurriculumName = request.getParameter("CurriculumName");
			 String CurriculumTeacherID = request.getParameter("CurriculumTeacherID");
			 String CurriculumTime = request.getParameter("CurriculumTime");
			 String CurriculumMaxnum = request.getParameter("CurriculumMaxnum");
			 String CurriculumNownum = request.getParameter("CurriculumNownum");
			 
			 CurriculumBean curriculumbean = new CurriculumBean();			
			 curriculumbean.setCurriculumID(Integer.parseInt(CurriculumID));
			 curriculumbean.setCurriculumName(CurriculumName);
			 curriculumbean.setCurriculumTeacherID(Integer.parseInt(CurriculumTeacherID));
			 curriculumbean.setCurriculumTime(Integer.parseInt(CurriculumTime));
			 curriculumbean.setCurriculumMaxnum(Integer.parseInt(CurriculumMaxnum));
			 curriculumbean.setCurriculumNownum(Integer.parseInt(CurriculumNownum));
			 
			 CurriculumLogic curriculumLogic = new CurriculumLogic();
			 curriculumLogic.addCurriculum(curriculumbean);

			 out.print(1);
		 }
		
	}
	        
}
